<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/general.css"/>
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css"/>
		<link rel="stylesheet" type="text/css" href="../css/mui.poppicker.css"/>
		<style type="text/css">
			.membermain{
				width: 100%;
				
			}
			
			.place button{
				width:100%;
				color: #676664 !important;
			    border: 0 !important;
			    padding: 11px 15px;
			 	text-align: right;
			}
			.place{
			}
			.inpr{
				text-align: right;
			}
			.mui-input-row .mui-btn {
			    float: right;
			    width: 60%;
			    padding: 11px 15px;
			}
			.borbot{
				border-bottom: 1px solid #BBBBBB;
			}
			.name>div,.content>div,.footbz>div{
				padding: 2px;
			}
			.name,.content,.footbz{
				padding: 5px 0;
			}
			.name,.content,.footbz{
				background-color: white;
			}
			.gd{
				width: 100%;
				height: 5px;
			}
			.mui-btn-block {
    font-size: 18px;
    display: block;
    width: 100%;
    margin-bottom: 0px;
    padding: 15px 0;
}
*{
	font-size: 0.95em;
}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">交班</h1>
		    <div class="ic mui-icon-right-nav mui-pull-right" onclick="gopage()">交班历史</div>
		</header>
		<div class="mui-content">
		    <div class="membermain">
		    	<div class="name">
		    	<div class="mui-input-row borbot">
		    			<label>交班时间</label>
			    		<div class="place items" >
						    <button id='birthday' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">日期选择</button>
						</div>
		    	</div>
		    	</div>
		    	<div class="name">
		    		<div class="mui-input-row borbot">
		    		    <label>下放营业额</label>
		    		    <input id="inhere_money" type="number" class="inpr" placeholder="请输入下放营业额" >
		    		</div>
		    		<div class="mui-input-row">
		    		        <label>上交营业额</label>
		    		        <input id="hand_in" type="number" class="inpr" placeholder="请输入上交营业额">
		    		    </div>
		    	</div>
		    	<div class="gd"></div>
		    	<div class="content">
		    		<!--
                    	作者：592176224@qq.com
                    	时间：2019-01-02
                    	描述：
		    		<div class="mui-input-row borbot" >
		    			<label>等级</label>
			    		<div class="place items" >
						    <button id='level' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">等级选择</button>
						</div>
		    		</div>
                    -->
		    		<div class="mui-input-row borbot">
		    		    <label>当前营业</label>
		    		    <input id="current_money" type="number" class="inpr" placeholder="请输入当前营业">
		    		</div>
		    		<div class="mui-input-row borbot">
		    		    <label>前班结余</label>
		    		    <input id="before_work_money" type="number" class="inpr" placeholder="请输入前班结余">
		    		</div>
		    		<div class="mui-input-row borbot">
		    		    <label>微信支付</label>
		    		    <input id="wxpay_money" type="number" class="inpr" placeholder="请输入微信支付" >
		    		</div>
		    		<div class="mui-input-row borbot">
		    		    <label>支付宝支付</label>
		    		    <input id="alipay_money" type="number" class="inpr" placeholder="请输入支付宝支付">
		    		</div>
		    		
		    		<div class="mui-input-row borbot">
		    		    <label>现金支付</label>
		    		    <input id="cash_money" type="number" class="inpr" placeholder="请输入现金支付">
		    		</div>
		    		<div class="mui-input-row borbot">
		    		    <label>银行卡支付</label>
		    		    <input id="bank_money" type="number" class="inpr" placeholder="请输入银行卡支付">
		    		</div>
		    		<div class="mui-input-row">
		    		    <label>其他支付</label>
		    		    <input id="other_moeny" type="number" class="inpr" placeholder="请输入其他支付">
		    		</div>
		    	</div>
		    	<div class="gd"></div>
		    	<div class="footbz">
		    		<div class="mui-input-row">
		    		    <label>备注</label>
		    		    <input type="text" class="inpr" maxlength="50" placeholder="限制50字内">
		    		</div>
		    	</div>
		    </div>
		    
		    
		    <div class="fgd"></div>
		    <div class="footdiv">
		    	<button id="swap_work" type="button" class="mui-btn mui-btn-blue mui-btn-block">交班</button>
		    </div>
		    
		</div>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.picker.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.poppicker.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/city.data.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			window.onload = function(){
				mui.init();
				
				
				mui.ready(function() {
                
                var birthday = document.getElementById('birthday');
                birthday.addEventListener('tap', function(event) {
                	//Datetime
                	var birthdayPicker = new mui.DtPicker({
	                    type: "datetime",//设置日历初始视图模式    //真正的月份比写的多一个月。  type的类型你还是可以选择date, datetime month time  hour 
	                    beginDate: new Date(2019, 01, 01, 0, 0),//设置开始日期   
	                    endDate: new Date(2050, 12, 31, 0, 0),//设置结束日期    //真正的是10.21
	                    labels: ['年', '月', '日', '时', '分'],//设置默认标签区域提示语 
                	})
                    birthdayPicker.show(function(e) {
                    	 birthday.innerText = e.y.text+"-"+e.m.text+"-"+e.d.text+" "+e.h.text+":"+e.i.text+":00";
                    });
                }, false);
                
                var flag = false;	//按钮未点
                g("swap_work").addEventListener("tap",function(res){
                	if(flag){
                		return;
                	}
                	flag = true;
                	var end_time = g("birthday").innerText;
                	if(end_time == "日期选择"){
                		mui.toast("请选择交班时间！");
                		flag = false;
                		return;
                	}
                	
                	var data = {
                		url:"/api/employee/swap_work",
                		data:{
                			access_token:acctoken(),
                			end_time:end_time,
                			inhere_money:g("inhere_money").value||0,
                			hand_in:g("hand_in").value||0,
                			current_money:g("current_money").value||0,
                			before_work_money:g("before_work_money").value||0,
                			wxpay_money:g("wxpay_money").value||0,
                			alipay_money:g("alipay_money").value||0,
                			cash_money:g("cash_money").value||0,
                			other_money:g("other_moeny").value||0,
                			bank_money:g("bank_money").value||0,
                		}
                	}
                	flag = false;
                	ajax(data,function(res){
                		console.log(res);
                		mui.toast(res.msg);
                		setTimeout(function(){
                			
                			plus.runtime.quit();
                		},1000)
                		
                	})
                	
                	
                })
				
			})
				get_work();
			}
			
			
			function get_work(){
				var data = {
					url:"/api/employee/get_work",
					data:{
						access_token:acctoken()
					}
				}
				ajax(data,function(res){
					console.log(res);
					if(res.data.all_money){
						g("current_money").value = res.data.all_money;
					}
					if(res.data.wxpay_money){
						g("wxpay_money").value = res.data.wxpay_money;
					}
					if(res.data.alipay_money){
						g("alipay_money").value = res.data.alipay_money;
					}
					if(res.data.cash_money){
						g("cash_money").value = res.data.cash_money;
					}
					if(res.data.bank_money){
						g("bank_money").value = res.data.bank_money;
					}
					if(res.data.other_moeny){
						g("other_moeny").value = res.data.other_moeny
					}
					
				})
			}
			
			function gopage(){
				mui.openWindow({
				    url: 'successrecord.html', 
				    id: 'successrecord'
				 });
			}
		</script>
	</body>

</html>